package com.youku.component.connection;

import java.util.Map;

import redis.clients.jedis.Jedis;

public class RedisConnector implements Connector {

	private Jedis jedis;

	private Map<String, String> map;

	@Override
	public Connector build(Map<String, String> map) {
		this.map = map;
		jedis = new Jedis(map.get("ip"), port());
		return null;
	}

	private int port() {
		String port = map.get("port");
		return port == null ? defaultPort() : Integer.parseInt(port);
	}

	@Override
	public int defaultPort() {
		return 6379;
	}

	public Jedis getJedis() {
		return jedis;
	}

}
